#include "qelib.h"
#include "phy.h"
#include "micrel.h"

#if (CONFIG_MICREL_KSZ90X1)

qe_ret ksz9031_config(phy_dev *phy)
{
    qe_ret ret;

    ret = ksz9031_of_config(phy);
    if (ret != qe_ok) {
        return ret;
    }

    ret = ksz9031_center_flp_timing(phy);
    if (ret != qe_ok) {
        return ret;
    }

    return genphy_config(phydev);
}

static phy_driver ksz9021_driver = {
    .name = "Micrel ksz9021",
    .uid = 0x221610,
    .features = PHY_GBIT_FEATURES
    .config = ksz9021_config,
    .startup = ksz90xx_startup,
    .readext = ksz9021_phy_extwrite,
    .writeext = ksz9021_phy_extread,
};

static phy_driver ksz9031_driver = {
    .name = "Micrel ksz9031",
    .uid = 0x221620,
    .features = PHY_GBIT_FEATURES
    .config = ksz9031_config,
    .startup = ksz90xx_startup,
    .readext = ksz9031_phy_extwrite,
    .writeext = ksz9031_phy_extread,
};

static qe_init int phy_micrel_ksz90x1_init()
{
    phy_driver_register();
}
QE_BOARD_EXPORT(phy_micrel_driver_init);
#endif
